package generator

import (
	"fmt"
	"github.com/astaxie/beego"
	"github.com/bwmarrin/snowflake"
)

var (
	node *snowflake.Node
)

func init() {
	var err error
	node, err = snowflake.NewNode(beego.AppConfig.DefaultInt64("node",1))
	if err != nil {
		panic(fmt.Sprintf("id generator snowflake.NewNode error %v", err))
	}
}

func GenerateId() string {
	return fmt.Sprintf("%d", node.Generate())
}
